 
package view;
 
import openhome.bo.DispositivosBO;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class DispositivosTipos extends javax.swing.JInternalFrame {
 
    public DispositivosTipos() {
        initComponents();
        this.consultar();
    }
public void consultar(){
        
        Map param = new HashMap();
        try {
            DispositivosBO dispo = new DispositivosBO();
        
            ResultSet rs = (ResultSet)dispo.traerDispositivosTipos();
            DefaultTableModel z = new DefaultTableModel();
            z.addColumn("ID");
            z.addColumn("TIPO DISPOSITIVO");
                         
            Object[] fila = new Object[2];
            while(rs.next()){                
                fila[0]= rs.getInt("idtipo_dispositivo");
                fila[1]= rs.getString("tipo_dispositivo");                
                z.addRow(fila);
            }            
            tbTipoDispositivo.setModel(z);
            tbTipoDispositivo.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
            //tbTipoDispositivo.getColumnModel().getColumn(0).setMaxWidth(0);
            //tbDispositivos.setEditable(false);
            //tbPersonal.getColumnExt(0).setVisible(false);           
        } catch (Exception ex) {
          Logger.getLogger(DispositivosBO.class.getName()).log(Level.SEVERE, null, ex);
        }        
}
  
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        jPanel2 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        txtSalir = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbTipoDispositivo = new javax.swing.JTable();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setTitle("TIPOS DISPOSITIVOS");

        jToolBar1.setBackground(new java.awt.Color(0, 0, 0));
        jToolBar1.setRollover(true);

        jPanel2.setBackground(new java.awt.Color(0, 0, 0));
        jPanel2.setLayout(new java.awt.GridLayout(1, 0));

        jButton1.setText("Nuevo");
        jPanel2.add(jButton1);

        jButton3.setText("Editar");
        jPanel2.add(jButton3);

        jButton4.setText("Anular");
        jPanel2.add(jButton4);

        jButton5.setText("Eliminar");
        jPanel2.add(jButton5);

        jButton6.setText("Exportar XLS");
        jButton6.setFocusable(false);
        jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jPanel2.add(jButton6);

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 23, Short.MAX_VALUE)
        );

        jPanel2.add(jPanel1);

        txtSalir.setText("Salir");
        txtSalir.setFocusable(false);
        txtSalir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        txtSalir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        txtSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtSalirActionPerformed(evt);
            }
        });
        txtSalir.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                txtSalirAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });
        jPanel2.add(txtSalir);

        jToolBar1.add(jPanel2);

        tbTipoDispositivo.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tbTipoDispositivo);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
                .addGap(5, 5, 5)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtSalirAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_txtSalirAncestorAdded
        // TODO add your handling code here:
    }//GEN-LAST:event_txtSalirAncestorAdded

    private void txtSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtSalirActionPerformed
        this.dispose();
    }//GEN-LAST:event_txtSalirActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JTable tbTipoDispositivo;
    private javax.swing.JButton txtSalir;
    // End of variables declaration//GEN-END:variables
}
